#include "stdafx.h"

void GraphKernelAllRootPairs::SetParameters(RootedGraphKernel &rootedGraphKernel)
{
    _rootedGraphKernel = &rootedGraphKernel;
}

double GraphKernelAllRootPairs::Evaluate(const Graph &g0, const Graph &g1) const
{
    double result = 0.0;
    _rootedGraphKernel->SetGraphs(g0, g1);

    for(UINT g0NodeIndex = 0; g0NodeIndex < g0.nodes().Length(); g0NodeIndex++)
    {
        const Node &n0 = g0.nodes()[g0NodeIndex];
        for(UINT g1NodeIndex = 0; g1NodeIndex < g1.nodes().Length(); g1NodeIndex++)
        {
            const Node &n1 = g1.nodes()[g1NodeIndex];
            double term = _rootedGraphKernel->Evaluate(n0, n1);
            result += term;
        }
    }
    return result;
}
